<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:c="http://java.sun.com/jstl/core"
  template="/WEB-INF/layouts/templateAdmin.xhtml">

  <ui:define name="menu">
    <!-- INCLUDE MENU -->
  </ui:define>

  <ui:define name="content">
    <!-- INCLUDE CONTENT -->
    <h1 class="pageTitle">Edit product</h1>

    <h:form>
      <h:commandLink action="back">
        Back to main page
      </h:commandLink>
    </h:form>

    <br />

    <span class="inlineText">On this page you can view and edit
      all product of application. There are #{flowScope.getNbProduct}
      products in base.</span>

    <h:form id="listProduct">
      <h:dataTable border="2" cellpadding="2" cellspacing="2" first="0"
        rows="#{flowScope.getNbProduct}" width="100%" dir="LTR"
        frame="border" rules="all" rowClasses="row1, row2"
        headerClass="head" columnClasses="column,,,column"
        value="#{flowScope.getProducts}" var="product" bgcolor="#F1F1F1"
        id="persons">

        <h:column>
          <f:facet name="header">
            <f:verbatim>Product ID</f:verbatim>
          </f:facet>

          <h:commandLink id="uid" value="#{product.ASIN}" action="show"
            title="#{product.name}">
            <f:setPropertyActionListener value="#{product}"
              target="#{flowScope.selectedProductRow}" />
          </h:commandLink>
        </h:column>

        <h:column>
          <f:facet name="header">
            <f:verbatim>Name</f:verbatim>
          </f:facet>
          <h:outputText value="#{product.name}" />
        </h:column>

        <h:column>
          <f:facet name="header">
            <f:verbatim>Categorie</f:verbatim>
          </f:facet>
          <h:selectOneMenu value="#{product.categoryId}" id="category"
            disabled="true">
            <f:selectItem itemValue="-1" itemLabel="--" />
            <c:forEach items="${conversationScope.sections}" var="e">
              <f:selectItem itemValue="#{e.id}" itemLabel="#{e.name}" />
            </c:forEach>
          </h:selectOneMenu>
        </h:column>

        <h:column>
          <f:facet name="header">
            <f:verbatim>Actions</f:verbatim>
          </f:facet>
          <h:commandButton value="Modify" action="modify" type="submit">
            <f:setPropertyActionListener value="#{product}"
              target="#{flowScope.selectedProductRow}" />
          </h:commandButton>

          <h:commandButton value="Delete" action="delete" type="submit">
            <f:setPropertyActionListener value="#{product}"
              target="#{flowScope.selectedProductRow}" />
          </h:commandButton>
        </h:column>
      </h:dataTable>

      <br />
      <h:panelGrid columns="2" cellpadding="10">
        <h:commandButton value="Add Product" action="add" type="submit" />
        Click here for add a new product.
      </h:panelGrid>
    </h:form>

    <h:form>
      <h:commandLink action="back">
        Back to main page
      </h:commandLink>
    </h:form>
  </ui:define>
</ui:composition>
